<style>
  #permission_form {margin: 50px;}
  .form_err {color:red; font-size: 90%; font-style:italic}
  .module {margin:5px 2px; border: 1px solid #ccc;}
  .module span {margin: 3px 10px 3px 3px;display: inline-block;}
  .module_name {margin:1px; padding:5px; background: #eee}
</style>
    
<div style="margin:10px">
    <h1>User groups management</h1>
    <div>
        <a href="index.php?m=administration&a=view_group">Groups list</a> | 
        <a href="index.php?m=administration&a=create_group">Create new group</a> |
        Group permission #<?=$group_id?>
    </div>
    <form id="permission_form" action="index.php?m=administration&a=permissions&status=submit&group_id=<?=$group_id?>" method="POST">
    <?foreach($modules_permissions as $m => $v):?>
    <div class="module">
        <div class="module_name">Module: <b><?=$v['name']?></b></div>
        <div class="permissions">
        <?foreach($v['permissions'] as $per):?>
        <?
           $arr = explode('/',$per);$action = $arr[1];
           $checked = ($permissions[$per]==1)? 'checked' : '';
        ?>
        <span><input type="checkbox" <?=$checked?> name="<?=$per?>"><?=$action?></span>
        <?endforeach?>
        </div>
    </div>
    <?endforeach?>
    <input type="submit" value="Update Permissions">
    </form>
</div>